﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/MasterPage.master" AutoEventWireup="true" CodeFile="MyAccount.aspx.cs" Inherits="MyAccount" %>

<asp:Content ID="Content1" ContentPlaceHolderID="title" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
    .b-accountParams h2 {
    color: #02537A;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    padding: 0 0 0 10px;
}

.b-accountParams h3.title, .b-bulk h3.title, .b-DownloadInstructions h3.title {
    background: url("images/container-box-title-shadow.png") no-repeat scroll left bottom transparent;
    color: #02537A;
    font-size: 18px;
    font-weight: bold;
    line-height: 1.3;
    padding-bottom: 12px;
    padding-left: 10px;
}

.b-accountParams .b-param p {
    color: #444343;
    font-size: 12px;
    line-height: 1.7;
    padding-left: 10px;
}
</style>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentBoxFloatRightPlaceHolder" Runat="Server">
    <div class="b-accountParams">
		    <div class="b-title">
			    <div class="wrap">
				    <div class="h3">Tài khoản của tôi</div>
			    </div>
		    </div>

            <h2>Sản phẩm đã mua</h2>
            <table class="tblStyle">
			    <colgroup>
				    <col width="290"/>
				    <col/>
				    <col width="90"/>
				    <col/>
				    <col/>
			    </colgroup>
<% 
    NhaKinhDoanhDataContext db = new NhaKinhDoanhDataContext();
    TaiKhoan tk = (TaiKhoan)Session["TaiKhoan"];
    var query = (from p in db.PhieuDatHangs
                 where p.MaKhachHang == tk.MaKhachHang
                 orderby p.NgayDatHang descending
                 select p).Take(1);
    
    PhieuDatHang pdh = null;
    try
    {
        pdh = query.Single();
    }
    catch
    {
    }
    
    if (pdh != null)
    {
%>
                <tfoot>
                    <tr>
                        <td align="left"><p style="float:left;"><b>Ngày mua hàng: </b> <%= pdh.NgayDatHang %></p></td>
                        <td colspan="2" align="left">
                        <p><b>Phí vận chuyển: </b> <%= pdh.PhiVanChuyen.ToString("0.00") %> USD</p>
                        </td>
                        <td colspan="2" align="right">
                        <p><b>Tổng tiền: </b> <%= (pdh.ThanhTien + pdh.PhiVanChuyen).ToString("0.00") %> USD</p>
                        </td>
                    </tr>
                </tfoot>

			    <tbody><tr>
				    <th class="alignLeft noWrap">Tên sản phẩm</th>
				    <th class="noWrap">Số lượng</th>
				    <th class="noWrap">Đơn giá(USD)</th>
				    <th class="noWrap">Trạng thái</th>
				    <th class="noWrap">Xem lộ trình/Tải về</th>
			    </tr>
<%      
        foreach (CTPhieuDatHang ct in pdh.CTPhieuDatHangs)
        {
%>
                <tr>
		            <td class="alignLeft"><%= ct.TaiLieu.ProductName %></td>
		            <td><%= ct.SoLuong %></td>
		            <td><%= ct.GiaBan %></td>
                    <td class="alignLeft">
<% 
    if (pdh.MaTinhTrang == 0)
    {
        Response.Write("Đang chờ duyệt");
    }
    else if (pdh.MaTinhTrang < 4)
    {
        Response.Write("Đang chờ giao hàng");
    }
    else
    {
        Response.Write(pdh.TTPhieuDatHang.TenTinhTrang);
    }
%>                    
                    </td>
		            <td>
<% 
    if (ct.LoaiSanPham == 1 && pdh.MaTinhTrang==4)
    {
%>
                        <a href="Download.aspx?id=<%=ct.MaTaiLieu %>&cus=<%=pdh.MaKhachHang %>&ord=<%=pdh.MaPDH %>">Tải sản phẩm</a>
<%
    }
            
    if (ct.LoaiSanPham == 2 && pdh.MaTinhTrang == 4)
    {
%>
                        <a href="<%= pdh.LienKetTheoDoiVC %>">Xem lộ trình</a>
<%
    }         
%>
                    </td>
	            </tr>
<% 
        }
    }
%>
		    </tbody></table>

            <br />
		        <div style="width:170px;" class="button-style btn-a">
                    <a href="History.aspx"><i></i>Lịch sử mua hàng</a>
                </div>
            <br />

		    <div class="clr"></div>

		    <h2>Thông tin cá nhân (<a style="font-weight:normal;" href="EditAccount.aspx">chỉnh sửa</a>)</h2>
		    <table class="tblStyle">
			    <colgroup>
				    <col/>
				    <col width="290" align="left"/>
                    <col />
				    <col/>
			    </colgroup>
			    <tbody><tr>
				    <th class="alignLeft noWrap">Họ tên</th>
				    <th class="noWrap">Địa chỉ</th>
                    <th class="noWrap">E-mail</th>
				    <th class="noWrap">Điện thoại</th>
			    </tr>

	                <tr>
		                <td class="alignLeft"><%= tk.KhachHang.TenKhachHang %></td>
                        <td><%= tk.KhachHang.DiaChi %></td>
		                <td><%= tk.TenDangNhap %></td>
		                <td><%= tk.KhachHang.SoDienThoai %></td>
	                </tr>
	            
		    </tbody></table>

		   
			<%--<div class="clr"></div>
		    <br/>
			<div class="b-param">
				<h3 class="title">Email alerts</h3>           
				<p>
					<a href="https://sec.ebooks.com/account/alerts/unsubscribe.asp?email=anhhung123@gmail.com">Modify my email alert subscriptions</a>				
				</p>
				
				<div class="clr"></div>
				<p>&nbsp;</p>
			</div>--%>
			
			 

		    <%--<div class="b-param">
			    <h3 class="title">Redeem a Voucher  </h3>
			    <p><b>What are Vouchers?</b></p>
			    <p>A Voucher enables the user to receive a free copy of an eBook. It is like a coupon code which is connected to an eBook. When you use a
    voucher, a copy of the eBook will be added to your account and you can download the eBook immediately.<br><a href="https://sec.ebooks.com/account/voucher.asp">Redeem a voucher</a></p>
			    <p class="padT10">* Please note that each voucher can be used once only.</p>
			    
                
			    <div class="clr"></div>
		    </div>--%>

			<%--<div class="b-param b-paramFirst">
			    <h3 class="title">MobiPocket Reader</h3>
			    <p>If you have an older phone or PDA, eBooks.com supports  MobiPocket Reader,  an ebook reading app that works on a wide range of older phones and PDAs. <br>
				In order to download MobiPocket Reader eBooks, you must register at least one Personal ID (PID). The PID is a unique identifier of your PDA or PC used by the Mobipocket Reader. It is displayed in the About Box of the Mobipocket Reader software.
			    <br/>
                    <a href="https://sec.ebooks.com/account/mobi.asp">Register a PID</a>
					</p>
			    <div class="clr"></div>
				<br/>
		    </div>--%>

            <div class="clr"></div>
		    <br/>

		    <div class="b-param">
			    <h3 class="title">Tư vấn & hỗ trợ kỹ thuật</h3>
			    <p><b><a class="noneTxtDecoration" href="#">Bạn cần hỗ trợ kỹ thuật?</a></b></p>
			    <p><a class="noneTxtDecoration" href="#">Thông tin cho khách hàng mới</a><br/>
				    <a class="noneTxtDecoration" href="#">Làm thế nào tôi có thể mua hàng?</a><br/>
				    <a class="noneTxtDecoration" href="#">Những gì khách hàng hay gặp phải?</a><br/>
                    <p class="padT5">Bạn đang gặp vấn để và cần trợ giúp? Hãy thử tìm kiếm câu trả lời từ danh sách trên.</p>

			    <!--<div class="button-style btn-a" style="width:95px;">
                    <a href="http://www.ebooks.com/help/" onclick="helpPop(this.href); return false;"><i></i>Get help</a>
                </div>-->
			    <div class="clr"></div>
				<p>&nbsp;</p>
		    </div>
	    </div>
</asp:Content>